﻿using System;
using System.Collections;
using System.Collections.Generic;

using AUV5.Model;
using AUV5.DAL.Interface;

namespace AUV5.DAL.Dao
{
    /// <summary>
    /// 功能：     InformList业务接口的实现
    /// 作者：     lwl
    /// 日期：     2011/10/14
    /// 修改日期： 
    /// 修改人：
    /// 修改内容：
    /// </summary>
    public class InformListSqlMapDao : BaseSqlMapDao, IInformListDao
    {
        private static InformListSqlMapDao instance = null;
        private static object syncRoot = new object();

        private InformListSqlMapDao()
        {
            //
            // TODO: 此处添加InformListSqlMapDao的构造函数
            //
        }
        public static IInformListDao Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (syncRoot)
                    {
                        if (instance == null)
                        {
                            instance = new InformListSqlMapDao();
                        }
                    }
                }
                return instance;
            }
        }

        /// <summary>
        /// 得到最大行数
        /// </summary>
        /// <returns></returns>
        public int GetMaxCounts()
        {
            try
            {
                return (int)ExecuteQueryForObject("SelectInformListByMaxCounts", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到列表
        /// </summary>
        /// <returns></returns>
        public System.Collections.Generic.IList<InformList> GetList()
        {
            try
            {
                return ExecuteQueryForList<InformList>("SelectInformList", null);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 通过不同参数得到列表
        /// </summary>
        /// <param name="objParameters"></param>
        /// <returns></returns>
        public System.Collections.Generic.IList<InformList> GetListByParameters(object objParameters)
        {
            try
            {
                return ExecuteQueryForList<InformList>("SelectInformListByParameters", objParameters);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 得到明细
        /// </summary>
        /// <param name="ListID"></param>
        /// <returns></returns>
        public InformList GetDetail(System.String listid)
        {
            try
            {
                return ExecuteQueryForObject<InformList>("SelectInformList", listid) as InformList;
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 新建
        /// </summary>
        /// <param name="informlist"></param>
        /// <returns></returns>
        public object Add(InformList informlist)
        {
            //int id = GetId("InformList");
            //informlist.ListID = id;

            try
            {
                return ExecuteInsert("InsertInformList", informlist);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="informlist"></param>
        /// <returns></returns>
        public int Update(InformList informlist)
        {
            try
            {
                return ExecuteUpdate("UpdateInformList", informlist);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ListID"></param>
        /// <returns></returns>
        public int Delete(System.String listid)
        {
            try
            {
                return ExecuteDelete("DeleteInformList", listid);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="informlist"></param>
        /// <returns></returns>
        public int Delete(InformList informlist)
        {
            try
            {
                return ExecuteDelete("DeleteInformList", informlist.ListID);
            }
            catch
            {
                throw;
            }
        }

        /// <summary>
        /// 获取分页列表
        /// </summary>
        /// <param name="pager"></param>
        /// <returns></returns>
        public IList<InformList> GetPagedList(NetPager pager)
        {
            try
            {
                return ExecuteQueryForList<InformList>("GetPagedInform", pager);
            }
            catch 
            {
                
                throw;
            }
        }
    }
}
